<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
		<title>Pesquisar</title>
		
		<link rel="stylesheet" href="/requisiteworks/styles/normalize.css" />
		<link rel="stylesheet" href="/requisiteworks/styles/main.css" />
		
		<script type="text/javascript" src="/requisiteworks/scripts/raze.js" ></script>
		<script type="text/javascript" src="/requisiteworks/scripts/jsool-all.js" ></script>
		
		<script type="text/javascript">
			jsool.onReady(function(){
				js.core.EventManager.on(window,"focus",function(){
					Raze.queryNode("input[name=q]").focus();
				});
				
				var datatable = jsool.select("#data tr"),
					parent = window.opener,
					NUMERO = 0,
					NOME = 1,
					TELEFONE = 2,
					EMAIL = 3;

				datatable.on("click",function(ev){
					if(parent.onSelect){
						var cells = Raze.query("td",this);
						var func = {
							numero: parseInt(cells[NUMERO].innerHTML),
							nome: cells[NOME].innerHTML
						};
						parent.onSelect(func);
					}
				});

				Raze.queryNode("input[name=q]").focus();
			});

			
		</script>
	</head>
	
	<body>
		<div class="main">
			<div class="ribbon" style="padding: 5px 0;margin:0;">
				<form action="/requisiteworks/funcionario/util/pesquisar.do" method="POST">
					<label>Pesquisar:</label>
					<input type="text" name="q"/>
					<button type="submit">Enviar</button>
				</form>
			</div>
			
			<div class="content">
				<c:if test="${not empty erro}">
					<div class="erro">${erro}</div>
				</c:if>
				<fieldset>
					<legend>Resultados</legend>
					
					<table class="data-table">
						<thead>
							<tr>
								<th>#</th>
								<th>Nome</th>
								<th>Email</th>
								<th>&#160;</th>
							</tr>
						</thead>
						<tbody id="data">
							<c:forEach items="${funcionarioList}" var="funcionario">
								<tr>
									<td>${funcionario.numero}</td>
									<td>${funcionario.nome}</td>
									<td>${funcionario.email}</td>
									<td>
										<a href="#" title="Adicionar Funcinario">
											<img src="/requisiteworks/images/add.png" alt="Adicionar Funcionario"/>
										</a>
									</td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
				</fieldset>
			</div>
		</div>
	</body>
</html>